<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">
        <h:form>
            <h:panelGrid columns="3">
                <h:outputLabel value="Select Outlet: " style="font-weight: bold"/>
                <h:selectOneListbox id="selectOutletList" value="#{dishManagedBeanTCube.outletId}">
                    <f:selectItems var="o" value="#{dishManagedBeanTCube.allOutlets}"
                                   itemValue="#{o.id}"
                                   itemLabel="#{o.stakeholder.name}, #{o.outletName}"/>
                </h:selectOneListbox>
                <p:commandButton id="selectOutletSubmit" value="Go" ajax="false"
                                 update="mealList" >
                </p:commandButton>
            </h:panelGrid>
        </h:form>

        <hr/>
        <br/>
        <h:form>
            <p:ajaxStatus style="width:20px;height:20px;">
                <f:facet name="start">
                    <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value="" />
                </f:facet>
            </p:ajaxStatus>
            <p:dataTable id="mealList" var="dishes" value="#{dishManagedBeanTCube.allDishes}" 
                         emptyMessage="Currently no dishes exist for this outlet"
                         dynamic ="true" paginator="true" paginatorPosition="top" 
                         rows="20">

                <f:facet name="header">
                    Existing Outlet Dishes
                </f:facet>

                <p:column headerText="Dish id" >
                    <h:outputText id="id" value="#{dishes.id}" />
                </p:column>
                <p:column headerText="Name">
                    <h:outputText id="name" value="#{dishes.name}" />
                </p:column>
                <p:column headerText="Price" style="width:9%">
                    <h:outputText id="stakeholder" value="#{dishes.price}" />
                </p:column>
                <p:column headerText="Type" filterBy="#{dishes.type}" 
                          filterOptions="#{dishManagedBeanTCube.dishTypeOptions}"  
                          filterMatchMode="exact">
                    <h:outputText id="dos" value="#{dishes.type}"/> 
                </p:column>
                <p:column headerText="locked?" filterBy="#{dishes.locked}"
                          filterOptions="#{dishManagedBeanTCube.lockedOptions}"  
                          filterMatchMode="exact">
                    <h:outputText id="status" value="#{dishes.locked? 'Yes':'No'}" />
                </p:column>
                <p:column headerText="Options">
                    <p:commandButton id="lockDish" value="Lock" ajax="false"
                                     update="display" disabled="#{dishes.locked ? true : false }"
                                     actionListener="#{promotionManagedBeanRep.lockDish}">
                        <f:attribute name="dishId" value="#{dishes.id}" />
                    </p:commandButton>
                    <p:commandButton id="unlockDish" value="unlock" ajax="false"
                                     update="display" disabled="#{dishes.locked ? false : true }"
                                     actionListener="#{promotionManagedBeanRep.unlockDish}">
                        <f:attribute name="dishId" value="#{dishes.id}" />
                    </p:commandButton>

                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>

</ui:composition>
